﻿using COUP.Core.Enums;

namespace COUP.Core.Networking
{
    public unsafe class MovementPacket : Packet
    {
        public MovementPacket(int Identifier, Direction Angle, Speed Speed)
        {
            Length = 12;
            Type = 1005;
            Int(Identifier);
            Byte((byte)Angle);
            Byte((byte)Speed);
        }

        public MovementPacket(Packet Data)
        {
            buffer = Data.Buffer;
        }

        public Direction Direction
        {
            get
            {
                fixed (byte* ptr = buffer)
                    return (Direction)(*(ptr + 8) % 8);
            }
        }

        public Speed Speed
        {
            get
            {
                fixed (byte* ptr = buffer)
                    return (Speed)(*(ptr + 9));
            }
        }
    }
}
